
const { ccclass, property } = cc._decorator;

@ccclass
export class GroundSprite extends cc.Component {

    isTouchBall : boolean = false;
    game:any = null;
    
    onBeginContact(contact, selfCollider, otherCollider) {
        if (otherCollider.node.name == "ballSprite") {
            otherCollider.node.destroy();
            if (this.isTouchBall == false) {
                this.game.firstBallPositionX = otherCollider.node.x;
                this.isTouchBall = true;
                this.game.isFirstBall = true;
            }
            this.game.tampBalls ++;
            if (this.game.tampBalls == this.game.allBalls) {    
                this.game.allBalls += this.game.addBalls;
                this.game.addBalls = 0;
                this.game.ballDown = true;
                this.game.tampBalls = 0;
                this.isTouchBall = false;
                this.game.isActivity = false;
                this.game.allBallsLabel.getComponent(cc.Label).string = "弹球数量: " + this.game.allBalls;
            }
        }
    }
}